#ifndef STARLING_CONNECTION_H_
#define STARLING_CONNECTION_H_

#include "basic_types.h"

#include <time.h>

namespace Starling
{
enum ConnectionFlags {
  //STARLING_CONNECTION_HTML       = 0x0001, /**< Connection sends/receives in 'HTML'. */
  //STARLING_CONNECTION_NO_BGCOLOR = 0x0002, /**< Connection does not send/receive background colors.                  */
  //STARLING_CONNECTION_AUTO_RESP  = 0x0004,  /**< Send auto responses when away.       */
  //PURPLE_CONNECTION_FORMATTING_WBFO = 0x0008, /**< The text buffer must be formatted as a whole */
  //PURPLE_CONNECTION_NO_NEWLINES = 0x0010, /**< No new lines are allowed in outgoing messages */
  //PURPLE_CONNECTION_NO_FONTSIZE = 0x0020, /**< Connection does not send/receive font sizes */
  //PURPLE_CONNECTION_NO_URLDESC = 0x0040,  /**< Connection does not support descriptions with links */
  //PURPLE_CONNECTION_NO_IMAGES = 0x0080,  /**< Connection does not support sending of images */
  //PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY = 0x0100 /**< Connection supports sending and receiving custom smileys */

};

enum ConnectionState {
  CS_DISCONNECTED = 0, /**< Disconnected. */
  CS_CONNECTED,        /**< Connected.    */
  CS_CONNECTING        /**< Connecting.   */

};

enum ConnectionError {
  CE_NETWORK_ERROR = 0,
  CE_INVALID_USERNAME = 1,
  CE_AUTHENTICATION_FAILED = 2,
};

struct ConnectionErrorInfo {
  ConnectionError m_type;
  char* description;
};

class Connection {
public:
private:
  ConnectionFlags m_flags;
  ConnectionState m_state;

  Account* m_account;
  char* m_password;
  int m_inpa;                 // The input watcher

  GSList* m_buddy_chats;

  void* m_proto_data;         // Protocol-specific data
  char* m_display_name;
  UINT m_keep_alive;

  /** Wants to Die state.  This is set when the user chooses to log out, or
  * when the protocol is disconnected and should not be automatically
  * reconnected (incorrect password, etc.).  prpls should rely on
  * purple_connection_error_reason() to set this for them rather than
  * setting it themselves.
  * @see purple_connection_error_is_fatal
  */
  bool m_wants_to_die;

  UINT disconnect_timeout;    /**< Timer used for nasty stack tricks  */
  time_t last_received;        /**< When we last received a packet. Set by the
                               prpl to avoid sending unneeded keepalives */
};
}
#endif // STARLING_CONNECTION_H_